﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<CRM.Database.Model.TechnicRequestsExt>" %>
<%--<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<CRM.Models.TechnicRequestsExt>" %>--%>
<%@ Import Namespace="CRM.Resourses" %>
<%@ Import Namespace="CRM.Controllers" %>

<% using (Html.BeginForm("TechnicRequestEdit", "TD", FormMethod.Post, new { @class = "edit_form" }))
    {
        var statusesCol = new CRM.Database.Model.TechnicRequestStatusesCollection();
        var usersCol = new CRM.Database.Model.UsersCollection();
%>
    <%: Html.ValidationSummary(true) %>
    <%:Html.Hidden("Key")%>
    <%:Html.Hidden("Request.IdCustomer")%>
    <%:Html.Hidden("Request.BeginDate")%>
    <%:Html.Hidden("Request.EndDate")%>
    <%:Html.Hidden("Request.CreateDate")%>
    
<table>
    <tr>
        <td>
            <%:Html.DevExpress().Label(settings =>
                    {
                        settings.ControlStyle.CssClass = "lable";
                        settings.Text = "Статус";
                        settings.Width = 120;
                    }).GetHtml() %>
        </td>
        <td>
            <%Html.DevExpress().ComboBox(settings =>
                    {
                        settings.Name = "Request.IdTechnicRequestStatus";
                        settings.Properties.ValueType = typeof(int);
                        settings.Properties.TextField = "LocalizedName";
                        settings.Width = 120;
                        settings.Properties.ValueField = "IdTechnicRequestStatus";
                    }).BindList(statusesCol.TechnicRequestStatusesList).Bind(Model.Request.IdTechnicRequestStatus).GetHtml();
                    //}).BindList(DB.TechnicRequestStatuses).Bind(Model.Request.IdTechnicRequestStatus).GetHtml();
                    
                    %>
        </td>
    </tr>
</table>
    
    <% Html.RenderPartial("TechnicRequestsDatesPartial", Model.Request); %>

    <table>
        <tr>
            <td>
                <%:Html.DevExpress().Label(settings =>
                      {
                          settings.ControlStyle.CssClass = "lable";
                          settings.Text = "Дата выезда";
                          settings.Width = 162;
                      }).GetHtml() %>
                <%:Html.DevExpress().DateEdit(settings =>
                        {
                            settings.Name = "Request.PlannedDate";
                            settings.Properties.DisplayFormatString = "D";
                            settings.Width = 162;
                        }).Bind(Model.Request.PlannedDate).GetHtml() %>
            </td>
            <td>
                <%:Html.DevExpress().Label(settings =>
                      {
                          settings.ControlStyle.CssClass = "lable";
                          settings.Text = "Техник";
                          settings.Width = 162;
                      }).GetHtml() %>
                <%Html.DevExpress().ComboBox(settings =>
                    {
                        settings.Name = "Request.IdTechnic";
                        settings.Properties.ValueType = typeof(int);
                        settings.Properties.TextField = "UserFullNameRu";
                        settings.Width = 162;
                        settings.Properties.ValueField = "IdUser";
                    }).BindList(usersCol.GetUsersByIdRoleType(3)).Bind(Model.Request.IdTechnic).GetHtml();
                    //}).BindList(DB.GetUsersByIdRoleType(3)).Bind(Model.Request.IdTechnic).GetHtml();
                    %>
            </td>
            <td>
                <%:Html.DevExpress().Label(settings =>
                      {
                          settings.ControlStyle.CssClass = "lable";
                          settings.Text = Resourses.TechnicDuration;
                          settings.Width = 162;
                      }).GetHtml() %>
                <%:Html.DevExpress().SpinEdit(settings =>
                    {
                        settings.Name = "Request.Duration";
                        settings.Properties.DisplayFormatString = "N1";
                        settings.Properties.Increment = (decimal)0.1;
                        settings.Width = 162;
                    }).Bind(Model.Request.Duration).GetHtml() %>
            </td>
        </tr>
    </table>
    
    <br />

    <%:Html.DevExpress().Label(settings =>
                  {
                      settings.ControlStyle.CssClass = "lable";
                      settings.Text = "Название юр. лица";
                      settings.Width = 232;
                  }).GetHtml() %>
    <%: Html.Partial("TechnicRequestLEPartial", Model)%>

    <br />

    <%:Html.DevExpress().Label(settings =>
                  {
                      settings.ControlStyle.CssClass = "lable";
                      settings.Text = "Контакты";
                      settings.Width = 232;
                  }).GetHtml() %>
    <%: Html.Partial("TechnicRequestContactPartial", Model)%>

    <br />
    
    <%:Html.DevExpress().Label(settings =>
                  {
                      settings.ControlStyle.CssClass = "lable";
                      settings.Text = "Адреса:";
                      settings.Width = 232;
                  }).GetHtml() %>
    <%: Html.Partial("TechnicRequestAddressesPartial", Model)%>

    <br />

    <%:Html.DevExpress().Label(settings =>
                  {
                      settings.ControlStyle.CssClass = "lable";
                      settings.Text = "Система:";
                      settings.Width = 232;
                  }).GetHtml() %>
    <%:Html.Action("TechnicRequestProductSystems", Model)%>
    
    <br />
    
    <%:Html.DevExpress().Label(settings =>
                  {
                      settings.ControlStyle.CssClass = "lable";
                      settings.Text = "Оборудование";
                      settings.Width = 232;
                  }).GetHtml() %>
    <%:Html.Action("TechnicRequestsEquipments", Model)%>
                  
    <br />

    <%:Html.DevExpress().Label(settings =>
                  {
                      settings.ControlStyle.CssClass = "lable";
                      settings.Text = "Тип выезда:";
                      settings.Width = 232;
                  }).GetHtml() %>
    <%: Html.Partial("TechnicRequestVisitsTypes", Model)%>

    <br />

    <%:Html.DevExpress().Label(settings =>
                  {
                      settings.ControlStyle.CssClass = "lable";
                      settings.Text = "Комментарий";
                      settings.Width = 500;
                  }).GetHtml() %>
    <%:Html.DevExpress().Memo( settings => 
                    {
                        settings.Name = "Request.Comments";
                        settings.Width = 500;
                        settings.Height = 100;
                    }).Bind(Model.Request.Comments).GetHtml()%>

    <br />

    <%:Html.DevExpress().Label(settings =>
                  {
                      settings.ControlStyle.CssClass = "lable";
                      settings.Text = "Прикрепляемые файлы:";
                      settings.Width = 232;
                  }).GetHtml() %>
    <%:Html.DevExpress().UploadControl(settings =>
       {
            settings.Name = "ucMultiFile";
            settings.AddUploadButtonsHorizontalPosition = AddUploadButtonsHorizontalPosition.Left;
            settings.FileInputCount = UploadControlDemosHelper.FileInputCount;
            settings.ShowAddRemoveButtons = true;
            settings.Width = 500;
            settings.FileInputCount = 1;
            //settings.ValidationSettings.Assign(UploadControlDemosHelper.ValidationSettings);
       }).GetHtml()%>

    <br />

    <button type="submit" value="Сохранить изменения">Сохранить изменения</button>
<% } %>